let i = 1;
let ports = {};
onconnect = function(e) { 
    let port = e.ports[0];
    console.error(e);
    ports[`${e.target.name}${i}`] = port;
    port.postMessage(`这是共享的数据:${e.data}，我是第${i}个窗口`); 
    
    port.onmessage = e =>{
        for(let key in ports) {
            ports[key].postMessage(e.data);
        }
    }
    i += 1;
}